{extend name="base"/}
{block name="content"}
<div id="header-frame">
    {include file="public:top" /}
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery-2.0.3.min.js'></script>
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery.form.js'></script>
    <link href="__STATIC__/admin/uploadajax/css/style.css" type="text/css" rel="stylesheet"/>
</div>
<div id="frame-body">
    <div id="menu-frame" style="width: 100%;float: left;">
        {include file="public:menu" /}


    </div>
    <div id="main-frame" style="float: left;">
        <div id="dcMain" style="margin-left: 0px;width: 1682px;">
            <!-- 当前位置 -->
            <div id="urHere">DouPHP 管理中心<b>></b><strong>添加分类</strong> </div>   <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
            <h3>添加分类</h3>
             <style>
            	.tableBasic tr th,td{
            		height: 40px;
            	}
            	.btn{
            		width:100px;
            		height: 40px;
            		text-align: center;
            		line-height: 40px;
            		font-size: 18px;
            		margin:10px 50px;
            		padding: 0;
            		font-weight: 100;
            	}
            </style>
            <form action="" id="data_type" method="post">
                <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                    <tr>
                        <td width="80" align="right">发货人姓名</td>
                        <td>
                            <input type="text" id="place_name" name="place_name" value="" size="40" class="inpMain" />
                        </td>
                    </tr>

                    <tr>
                        <td width="80" align="right">发货地址</td>
                        <td>
                        <select onchange="cChange(this)" id="p" name="addr_p">

                        </select>
                        <select  onchange="dChange(this)" id="c" name="addr_c">

                        </select>
                        <select id="d" name="addr_d">

                        </select>
                            <script src="__STATIC__/area.js"></script>
                            <script>
                                console.log(data);
                                var pstr="";
                                for (var kay in data[100000]){
                                    pstr+="<option value='"+kay+'/'+data[100000][kay]+"'>"+data[100000][kay]+"</option>";
                                }
                                $("#p").append(pstr);
                                var cstr="";
                                for (var kay in data[110000]){
                                    cstr+="<option  value='"+kay+'/'+data[110000][kay]+"'>"+data[110000][kay]+"</option>";
                                }
                                $("#c").append(cstr);
                                var dstr = "";
                                for (var kay in data[110100]) {
                                    dstr += "<option value='"+kay+'/'+data[110100][kay] +"'>" + data[110100][kay] + "</option>";
                                }
                                $("#d").append(dstr);
                                function cChange(that) {
                                    $("#c").html("");
                                    $("#d").html("");
                                    console.log(that.value)
                                    num=parseInt(that.value)
                                    var numm=num+100
                                    var cstr="";
                                    for (var kay in data[num]){
                                        cstr+="<option  value='"+kay+'/'+data[num][kay]+"'>"+data[num][kay]+"</option>";
                                    }
                                    $("#c").append(cstr);
                                    var dstr = "";
                                    for (var kay in data[numm]) {
                                        dstr += "<option value='"+kay+'/'+data[numm][kay] +"'>" + data[numm][kay] + "</option>";
                                    }
                                    $("#d").append(dstr);
                                }
                                function dChange(that) {
                                    $("#d").html("");
                                    num=parseInt(that.value)
                                    var dstr = "";
                                    for (var kay in data[num]) {
                                        dstr += "<option value='"+kay+'/'+data[num][kay] +"'>" + data[num][kay] + "</option>";
                                    }
                                    $("#d").append(dstr);
                                }
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td width="80" align="right">详细地址</td>
                        <td>
                        <input type="text" id="addr_detail" name="addr_detail" value="" size="40" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td width="80" align="right">发货人电话</td>
                        <td>
                        <input type="text" id="mobile" name="mobile" value="" size="40" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">邮编</td>
                        <td>
                            <input type="text" id="code" name="code" value="" size="5" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="hidden" name="token" value="b9439ae8" />
                            <input type="hidden" name="product_id" value="{$pid}" />
                            <input type="hidden" name="place_id" value="" />
                            <input  class="btn" type="button" onclick='protype_add()' value="提交" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        </div>
        <div class="clear"></div>
        <script type="text/javascript">
            function protype_add(){
                var success_url="{:url('admin/product/place')}";
                var url="{:url('admin/product/add_place')}";
                var admins=$("#data_type").serialize();
                //alert(admins);
                    $.post(url,admins,function(result){

                        if(result.status=='4')
                        {
                            dialog.success(result.message,success_url);
                        }else
                        {
                            dialog.error(result.message);
                        }
                    })
            }
        </script>
        {/block}